package dbms;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBSelectingFunctions {
	
	public static String getProgramParameter(String programName, int programParameter) throws SQLException
	{
		String sql = "SELECT value FROM " + DBTables.CONFIG + " WHERE program=? AND parameter=?";
		PreparedStatement ps = DBConnection.getIstance().prepareStatement(sql);
		ps.setString(1, programName);
		ps.setInt(2, programParameter);
		
		return DBGeneralFunctions.returnStringFromSingleValueResultSet(ps.executeQuery());		
	}
	
	/*
	public static String getProgramType(String programName) throws SQLException
	{
		String sql = "SELECT value FROM " + DBTables.CONFIG + " WHERE program=? AND parameter=?";
		PreparedStatement ps = DBConnection.getIstance().prepareStatement(sql);
		ps.setString(1, programName);
		ps.setString(2, "type");
		
		return DBSelectingFunctions.returnStringFromSingleValueResultSet(ps.executeQuery());
	}
	
	public static String getProgramDir(String programName) throws SQLException
	{
		String sql = "SELECT value FROM " + DBTables.CONFIG + " WHERE program=? AND parameter=?";
		PreparedStatement ps = DBConnection.getIstance().prepareStatement(sql);
		ps.setString(1, programName);
		ps.setString(2, "dir");
		
		return DBSelectingFunctions.returnStringFromSingleValueResultSet(ps.executeQuery());
	}
	
	public static String getProgramExecutingName(String programName) throws SQLException
	{
		String sql = "SELECT value FROM " + DBTables.CONFIG + " WHERE program=? AND parameter=?";
		PreparedStatement ps = DBConnection.getIstance().prepareStatement(sql);
		ps.setString(1, programName);
		ps.setString(2, "executingName");
		
		return DBSelectingFunctions.returnStringFromSingleValueResultSet(ps.executeQuery());
	}
	
	public static String getProgramExtenzion(String programName) throws SQLException
	{
		String sql = "SELECT value FROM " + DBTables.CONFIG + " WHERE program=? AND parameter=?";
		PreparedStatement ps = DBConnection.getIstance().prepareStatement(sql);
		ps.setString(1, programName);
		ps.setString(2, "extenzion");
		
		return DBSelectingFunctions.returnStringFromSingleValueResultSet(ps.executeQuery());
	}
	*/

}
